package jp.cane.android.luciferblue;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;

public class PollingActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.polling);

		Bundle extras = getIntent().getExtras();

		final EditText pollingStrings = (EditText) findViewById(R.id.pollingStrings);
		pollingStrings.setText(extras.getString("pollingStrings"));

		final EditText pollingInterval = (EditText) findViewById(R.id.pollingInterval);
		pollingInterval.setText("" + extras.getInt("pollingInterval"));

		final CheckBox pollingLoop = (CheckBox) findViewById(R.id.pollingLoop);
		pollingLoop.setChecked(extras.getBoolean("pollingLoop"));

		Button OK = (Button) findViewById(R.id.ok);
		OK.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent intent = new Intent();

				intent.putExtra("pollingStrings", pollingStrings.getText()
						.toString());
				intent.putExtra("pollingInterval",
						Integer.valueOf(pollingInterval.getText().toString()));
				intent.putExtra("pollingLoop", pollingLoop.isChecked());

				setResult(RESULT_OK, intent);
				finish();
			}
		});
	}
}
